﻿@model System.Collections.Generic.List<NetNote.Models.Note>

@{
    ViewBag.Title = "心动笔记";
    Layout = $"_Layout";
    var pageindex = Convert.ToInt32( ViewBag.PageIndex );
    var pagecount = Convert.ToInt32( ViewBag.PageCount );
    var pagestart = pageindex - 2 > 0 ? pageindex - 2 : 1;
    var pageend = pageindex + 2 >= pagecount ? pagecount : pagestart + 4;
}

<h2>心动笔记</h2>
<div class="container-fluid">
    <div class="row">
        <a asp-action="Add">添加Note</a>
    </div>
    @foreach (var item in Model)
    {
    @if (string.IsNullOrEmpty(item.Password))
     {
    <div class="row">
        <h3> <a asp-action="Detail" asp-route-id="@item.Id">@item.Title</a></h3>
        <h5>@item.Type.Name &emsp;<span style="font-size: 5px; color: cadetblue">@item.Create.ToString("yyyy-MM-dd mm:ss")</span></h5>
        <div class="tab-content" id="md_@item.Id">@item.Content</div>
        @if (!string.IsNullOrEmpty(item.Attachment))
             {
        <a href="@item.Attachment">下载</a>
             }
        <hr />
    </div>
     }
     else
     {
    <div class="row">
        <a asp-action="Detail" asp-route-id="@item.Id">内容已加密</a>
    </div>
     }
    }
</div>
<nav>
    <ul class="pager">
        <li class="@(pageindex==1?"disabled":"")"><a asp-action="index" asp-route-pageindex="@((pageindex==1)?1:pageindex-1)" )>&laquo;</a></li>
        @for (int i = pagestart; i <= pageend; i++)
        {
            if (i <= pagecount)
            {
        <li @(pageindex==i?"class=disabled":"")><a asp-action="index" asp-route-pageindex="@i">@i</a></li>
            }

        }
        <li class="@(pageindex==pagecount?"disabled":"")"><a asp-action="index" asp-route-pageindex="@(pageindex==pagecount?pagecount:pageindex+1)">&raquo;</a></li>
    </ul>
</nav>